package cn.zspt.vank.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class VankConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new JwtInterceptor()).addPathPatterns("/**")
                .excludePathPatterns("/login","/logout","/dishes_img/**",
                        "/verifyCode","/captchaImage","/admin/uploadDishImage","/swagger-ui/**","/v3/**");
    }

    @Value("${image.dishes_path}")
    private String dishesPath;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        /** 图片传路径 */
        registry.addResourceHandler("/dishes_img/**").addResourceLocations("classpath:/static/img/dishes/");
    }
}
